package LeetCodeHot100TopInterview;

public class Q206_ReverseList {
    //反转链表
    //同剑指offerQ24
    //快慢指针迭代
    public ListNode reverseList(ListNode head) {
        if (head == null){
            return null;
        }
        //记录状态
        ListNode pre = null;
        ListNode next = null;
        ListNode cur = head;
        while (cur != null){
            next = cur.next;
            cur.next = pre;
            pre = cur;
            cur = next;
        }
        return pre;

    }
}
